<template>
  <view class="container">
    <z-nav-bar backState='3000' @backClick='backClick' type='transparent' :titleCenter='true' title=''></z-nav-bar>
    <public-module></public-module>
    <div class="yewu-bg">
      <div class="yewu-list">
        <div v-for="item in yewuList" :key="item.id" @click="getpostData(item)" class="yewu-item">
          <div class="yewu-title">{{ item.typename }}</div>
          <div class="yewu-right">排队人数:{{ item.ddrs || 0 }}</div>
        </div>
      </div>
    </div>
    <view v-if="showCustomModal" class="custom-modal">
      <view class="modal-content">
        <view class="modal-header">
          <text class="modal-title">√打印成功，请拿走取号小票。</text>
          <view class="modal-close" @click="closeModal">x</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import $http from '@/config/requestConfig'
export default {
	data() {
		return {
			yewuList: [],
			depid: '',
			id: '',
			showCustomModal: false
		};
	},
	//第一次加载
	onLoad(options) {
		this.depid = options.depid || '';
		this.id = options.id || '';
		this.getYewuList();
	},
	//页面显示
	onShow() {
		uni.hideTabBar();
	},
	//方法
	methods: {
		getpostData(item) {
			let data = { pid: uni.getStorageSync('pid'), parentYwlxId: item.id, fwlx: 7 }
			$http.get('Person/dyjk', data).then(res => {
				if (res && res.data.length > 0) {
					this.showCustomModal = true;
				}
			}, err => {
				uni.showToast({ title: '获取部门失败', icon: 'none' });
			});
		},
		backClick() {
			uni.navigateBack()
		},
		getYewuList() {
			$http.get('Person/dadss', { depid: this.depid }).then(res => {
				if (res && res.data) {
					this.yewuList = res.data
				} else {
					this.yewuList = [];
				}
			}, err => {
				uni.showToast({ title: '获取业务失败', icon: 'none' });
			});
		},
		closeModal() {
			console.log(111)
			this.showCustomModal = false;
		}
	},
	//页面隐藏
	onHide() {},
	//页面卸载
	onUnload() {},
	//页面下来刷新
	onPullDownRefresh() {},
	//页面上拉触底
	onReachBottom() {},
	//用户点击分享
	onShareAppMessage(e) {
		
	}
};
</script>

<style scoped>
.yewu-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #165DFF 0%, #4080FF 50%, #6AA1FF 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 220rpx 0;
}
.yewu-list {
  width: 96%;
  display: flex;
  flex-direction: column;
  gap: 28rpx;
}
.yewu-item {
  background: #fff;
  border-radius: 12rpx;
  box-shadow: 0 2px 8px 0 rgba(22,93,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28rpx 32rpx;
  font-size: 2.5vh;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.yewu-item:active {
  transform: scale(0.98);
  background: #f8faff;
  box-shadow: 0 1px 4px 0 rgba(22,93,255,0.12);
}
.yewu-title {
  color: #222;
}
.yewu-right {
  color: #888;
  font-size: 2vh;
}
.custom-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100; display: flex; align-items: center; justify-content: center;
}
.modal-content { background: #fff; border-radius: 12px; width: 100%; max-width: 100vh; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid #eee; }
.modal-title { font-size: 6vh; font-weight: bold; }
.modal-close { font-size: 6vh; cursor: pointer; color: #999; }
</style>
